package com.example.service.impl;

import com.example.common.Result;
import com.example.entity.Relation;
import com.example.entity.Task;
import com.example.mapper.RelationMapper;
import com.example.service.RelationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lmy
 * @since 2024-08-04
 */
@Service
public class RelationServiceImpl extends ServiceImpl<RelationMapper, Relation> implements RelationService {


    @Override
    public List<Relation> findAlls() {
        return baseMapper.findAlls();
    }

    @Override
    public boolean insertRelation(Relation data) {
        String intermediatorId= data.getIntermediatorId();
        String salespersonId=data.getSalespersonId();
        Task task=new Task();
        task.setIntermediatorId(intermediatorId);
        task.setSalespersonId(salespersonId);
        task.setState(String.valueOf(0));
        task.setUpdateTime(LocalDateTime.now());
        task.setCreateTime(LocalDateTime.now());
        boolean b=baseMapper.insertRelation(data);
        if (b){return true;}else{
            return false;
        }
    }


}
